<!DOCTYPE html>
<html>

<head>
  <meta charset='utf-8'>
  <title>Mocha Tests</title>
  <link rel='stylesheet' href='../node_modules/mocha/mocha.css'>
  <link rel='stylesheet' href='../dist/iD.css'>
  <!-- <script src='../node_modules/d3/build/d3.js'></script> -->
  <style type='text/css'>
    /* apply standalone iD styling when testing */
    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }
  </style>
</head>

<body style="overflow:scroll">
  <div id='mocha'></div>

  <script src='../node_modules/mocha/mocha.js'></script>
  <script src='../node_modules/chai/chai.js'></script>
  <script src='../node_modules/sinon/pkg/sinon.js'></script>
  <script src='../node_modules/sinon-chai/lib/sinon-chai.js'></script>
  <script src='../node_modules/happen/happen.js'></script>

  <script>
    if (typeof initMochaPhantomJS === 'function') {
      initMochaPhantomJS()
    }
  </script>

  <script>
    var scripts = [
      'spec/actions/add_entity.js',
      'spec/actions/add_member.js',
      'spec/actions/add_midpoint.js',
      'spec/actions/change_member.js',
      'spec/actions/change_preset.js',
      'spec/actions/change_tags.js',
      'spec/actions/circularize.js',
      'spec/actions/connect.js',
      'spec/actions/copy_entities.js',
      'spec/actions/delete_member.js',
      'spec/actions/delete_multiple.js',
      'spec/actions/delete_node.js',
      'spec/actions/delete_relation.js',
      'spec/actions/delete_way.js',
      'spec/actions/discard_tags.js',
      'spec/actions/disconnect.js',
      'spec/actions/join.js',
      'spec/actions/merge.js',
      'spec/actions/merge_nodes.js',
      'spec/actions/merge_polygon.js',
      'spec/actions/merge_remote_changes.js',
      'spec/actions/move.js',
      'spec/actions/move_node.js',
      'spec/actions/noop.js',
      'spec/actions/orthogonalize.js',
      'spec/actions/restrict_turn.js',
      'spec/actions/reverse.js',
      'spec/actions/revert.js',
      'spec/actions/split.js',
      'spec/actions/straighten_nodes.js',
      'spec/actions/straighten_way.js',
      'spec/actions/unrestrict_turn.js',
      'spec/actions/reflect.js',
      'spec/actions/extract.js',
      'spec/actions/upgrade_tags.js',

      'spec/behavior/hash.js',
      'spec/behavior/hover.js',
      'spec/behavior/select.js',
      'spec/behavior/lasso.js',

      'spec/core/context.js',
      'spec/core/difference.js',
      'spec/core/file_fetcher.js',
      'spec/core/graph.js',
      'spec/core/history.js',
      'spec/core/tree.js',
      'spec/core/validator.js',

      'spec/geo/extent.js',
      'spec/geo/geo.js',
      'spec/geo/geom.js',
      'spec/geo/vector.js',

      'spec/lib/locale.js',

      'spec/modes/add_point.js',
      'spec/modes/add_note.js',

      'spec/operations/extract.js',
      'spec/operations/straighten.js',

      'spec/osm/changeset.js',
      'spec/osm/entity.js',
      'spec/osm/intersection.js',
      'spec/osm/multipolygon.js',
      'spec/osm/lanes.js',
      'spec/osm/node.js',
      'spec/osm/note.js',
      'spec/osm/relation.js',
      'spec/osm/way.js',

      'spec/presets/category.js',
      'spec/presets/collection.js',
      'spec/presets/index.js',
      'spec/presets/preset.js',

      'spec/renderer/background_source.js',
      'spec/renderer/features.js',
      'spec/renderer/map.js',
      'spec/renderer/tile_layer.js',

      'spec/services/mapillary.js',
      'spec/services/maprules.js',
      'spec/services/nominatim.js',
      'spec/services/openstreetcam.js',
      'spec/services/osm.js',
      'spec/services/osm_wikibase.js',
      'spec/services/streetside.js',
      'spec/services/taginfo.js',

      'spec/svg/areas.js',
      'spec/svg/data.js',
      'spec/svg/icon.js',
      'spec/svg/layers.js',
      'spec/svg/lines.js',
      'spec/svg/midpoints.js',
      'spec/svg/osm.js',
      'spec/svg/points.js',
      'spec/svg/svg.js',
      'spec/svg/tag_classes.js',
      'spec/svg/vertices.js',

      'spec/ui/cmd.js',
      'spec/ui/combobox.js',
      'spec/ui/confirm.js',
      'spec/ui/flash.js',
      'spec/ui/inspector.js',
      'spec/ui/modal.js',

      'spec/ui/sections/raw_tag_editor.js',

      'spec/ui/fields/access.js',
      'spec/ui/fields/localized.js',
      'spec/ui/fields/wikipedia.js',

      'spec/util/aes.js',
      'spec/util/array.js',
      'spec/util/clean_tags.js',
      'spec/util/keybinding.js',
      'spec/util/object.js',
      'spec/util/session_mutex.js',
      'spec/util/util.js',

      'spec/validations/almost_junction.js',
      'spec/validations/crossing_ways.js',
      'spec/validations/disconnected_way.js',
      'spec/validations/incompatible_source.js',
      'spec/validations/mismatched_geometry.js',
      'spec/validations/missing_role.js',
      'spec/validations/missing_tag.js',
      'spec/validations/outdated_tags.js',
      'spec/validations/private_data.js',
      'spec/validations/suspicious_name.js'
    ];

    var isPhantomJS = !!(navigator.userAgent.match(/PhantomJS/));
    var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));

    // Prepend scripts to run at the beginning.

    // Third Script?  PhantomJS can test some other capabilities
    if (isPhantomJS) scripts.unshift('spec/phantom.js');

    // Second Script:  Always run spec helpers
    scripts.unshift('spec/spec_helpers.js');

    // First script: Choose either modern or legacy iD build..
    scripts.unshift((isPhantomJS || isIE11) ? '../dist/iD.legacy.js' : '../dist/iD.js');


    // Create and execute all scripts in specified order..
    (function nextScript() {
      if (!scripts.length) {
        window.mocha.run();
        return;
      }
      var src = scripts.shift();
      var newScript;
      newScript = document.createElement('script');
      newScript.type = 'text/javascript';
      newScript.src = src;
      newScript.onload = nextScript;
      document.getElementsByTagName('body')[0].appendChild(newScript);
    })();
  </script>

</body>
</html>
